/******************* 公共变量 *******************/
var userId = core.getUrlData('user_id'),
	activityId = core.getUrlData('activity_id');

/******************* Vue初始化代码 *******************/
var vm = new Vue({
	el: '.wrap',
	data: {
		like: [],
		not_like: [],
		id: '',
		username: '',
		age: '',
		sex: '',
		star: '',
		photo_id: '',
		position: ''
	},
	methods: {
		showMore: function (event) {
			var $this = $(event.target);

			$this.hasClass('active') ? $this.removeClass('active').prev().removeClass('active') : $this.addClass('active').prev().addClass('active');
		},
		select: function (event) {
			var $this = $(event.target);

			if ($this.parent().children('.active').length >= 3) {
				$this.hasClass('active') ? $this.removeClass('active') : core.layerHint('每类评价最多选择3个标签哦~');
			} else {
				$this.hasClass('active') ? $this.removeClass('active') : $this.addClass('active');
			}
		},
		submit: function () {
			var likeArr = [],
				$like = $('html body .wrap .activity-evaluation .impression div .active'),
				notLikeArr = [],
				$notLike = $('html body .wrap .activity-evaluation .complain div .active');

			for (var i = 0; i < $like.length; i++) {
				likeArr.push($like.eq(i).html());
			}
			for (var j = 0; j < $notLike.length; j++) {
				notLikeArr.push($notLike.eq(j).html());
			}
			ajax.load({
				url: evaluationUrl,
				type: 'post',
				data: {
					user_id: userId,
					activity_id: activityId,
					like: likeArr,
					not_like: notLikeArr
				},
				callback: function (data) {
					console.log(data)

					if (data.status == 1) {
						core.hintBack(data.message);
					} else {
						core.layerHint(data.message);
					}
				}
			});
		}
	},
	computed: {
		
	},
	components: {
		
	},
	created: function () {
		/******************* 个人信息载入 *******************/
		var _this = this;
		ajax.load({
			url: evaluationInfoUrl,
			type: 'post',
			data: {user_id: userId},
			callback: function (data) {
				console.log(data)

				$.extend(_this, data.user);
				$.extend(_this, data);
			}
		});
	},
	mounted: function () {
		
	}
});

